<?php
require_once 'Zend/Validate/Abstract.php';
require_once 'Zend/Uri.php';


class Zend_Validate_JpegFile extends Zend_Validate_Abstract
{
	const MSG_JPG = 'msgJPG';

	protected $_messageTemplates = array(
	self::MSG_JPG => "Invalid file - only JPG is accrpted",
	);

	public function isValid($value)
	{
		$this->_setValue($value);

		//Validate the URI
		#   $valid = Zend_Uri::check($value);
		//Return validation result TRUE|FALSE
		$pattern = "/^.*\.(jpg|jpeg)$/i";
		if (preg_match($pattern, $value)) {
			return true;
		} else {
			$this->_error(self::MSG_JPG);
			return false;
		}


		#        if ($valid)  {
		#         #   return true;
		#        } else {
		#     #       $this->_error(self::MSG_JPG);
		#           return false;
		##
		#      }

	}
}

?>